import React from 'react';
import { connect } from 'dva';
import StockRequireApplyList from '../components/StockRequireApplyList';
import MainLayout from '../components/MainLayout';

class StockRequireApply extends React.Component{

  handleDelete = (id) =>{
    this.props.dispatch({
      type: 'stockrequireapply/delete',
      payload: id,
    });
  }

  createHandler = (values)=> {
    this.props.dispatch({
      type: 'stockrequireapply/create',
      payload: values,
    });
  }

  componentDidMount = () => {
    this.props.dispatch({
      type: 'stockrequireapply/loadServerData'
    });
  }

  render(){
    const {applyList,location } = this.props;
    return (
      <MainLayout location={location}>
        <StockRequireApplyList onDelete={this.handleDelete} createHandler={this.createHandler} applyList={applyList} />
      </MainLayout>
    );
  }
};

const mapStateToProps = state => {
    return {
      applyList:state.stockrequireapply.applyList
    }
}

export default connect(mapStateToProps)(StockRequireApply);